﻿using System;
using System.Collections.Generic;
using System.Data;
using Module.Common.Models;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;

namespace Module.Core.BusinessLogic
{
    public class ProductCartBL
	{
		/// <summary>
		/// Saves a record to the ProductCart table.
		/// </summary>
		public static int Insert(ProductCartInfo productCartInfo)
		{
			try
			{
				return new ProductCartDAO().Insert(productCartInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Saves a record to the ProductCart table.
		/// </summary>
        public static void Update(ProductCartInfo productCartInfo)
		{
			try
			{
				new ProductCartDAO().Update(productCartInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Delete a record from the ProductCart table.
		/// </summary>
        public static void Delete(int cartId)
		{
			try
			{
				new ProductCartDAO().Delete(cartId);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the ProductCart table.
		/// </summary>
        public static ProductCartInfo Select(int cartId)
		{
			try
			{
				return new ProductCartDAO().Select(cartId);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects all records from the ProductCart table.
		/// </summary>
        public static CHRTList<ProductCartInfo> SelectAll()
		{
			try
			{
				return new ProductCartDAO().SelectAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static int GetCount(DateTime createOnFrom, DateTime createOnTo)
        {
            try
            {
                return new ProductCartDAO().GetCount(createOnFrom, createOnTo);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static DataTable SearchAll(DateTime createdOnFrom,DateTime createdOnTo, int from, int to)
        {
            try
            {
                return new ProductCartDAO().SearchAll(createdOnFrom, createdOnTo, from, to);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>        
        /// <param name="isTotalRow">=True lấy tổng sổ bản ghi</param>
        /// <returns></returns>
        public static int SelectCount(bool isTotalRow)
        {
            try
            {
                return new ProductCartDAO().SelectCount(isTotalRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>
        /// <param name="beginRow">Bản ghi đầu tiên</param>
        /// <param name="endRow">Bản ghi kết thúc</param>
        /// <param name="orderByColumn">Điều kiện sắp xếp</param>       
        /// <returns></returns>
        public static DataTable Search(int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new ProductCartDAO().Search(beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        public static DataSet ListProductCartPage(int cartId, int productId, int memberId, DateTime createOnFrom, DateTime createOnTo, int currPage, int recodperPage, int pageSize, int total, string link)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new ProductCartDAO().ListProductCartPage(cartId, productId, memberId, createOnFrom, createOnTo, currPage,recodperPage,pageSize,total,link);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }

    }
}
